home *** CD-ROM | disk | FTP | other *** search
/ Aminet 21 / Aminet 21 (1997)(GTI - Schatztruhe)[!][Oct 1997].iso / Aminet / dev / amos / AMCAFExa.lha / AMCAF_Examples / VecRotWireFade.AMOS / VecRotWireFade.amosSourceCode
Encoding:
AMOS Source Code  |  1996-01-17  |  4.1 KB  |  134 lines

  1. ' ************************************* Commands used: 
  2. ' *                                   * Vec Rot Pos        Turbo Draw
  3. ' *           Amcaf Examples          * Vec Rot Angles     Blitter Clear 
  4. ' *  Vector Rotate Wire + Fade V1.1   * Vec Rot Precalc    =Qsin 
  5. ' *      Written by Chris Hodges      * =Vec Rot X 
  6. ' *                                   * =Vec Rot Y 
  7. ' ************************************* =Vec Rot Z 
  8. '                          
  9. ' Hide mouse pointer.
  10. Hide 
  11. ' Setup a nice little screen with double buffering 
  12. Screen Open 0,320,256,8,Lowres
  13. Curs Off : Flash Off : Paper 0 : Pen 1 : Cls 
  14. Palette 0,0,0,0
  15. Double Buffer 
  16. Autoback 0
  17. ' Read out, how many coords are used.
  18. Restore COORDS
  19. Read NUMCO
  20. ' Dim one field to keep these coords, and a second for the rotated.
  21. Dim CO(NUMCO,2),RC(NUMCO,1)
  22. ' Now read all coords in.
  23. For A=1 To NUMCO
  24.   Read CO(A,0),CO(A,1),CO(A,2)
  25. Next 
  26. ' Then, get the number of lines the object consists of.
  27. Restore LINES
  28. Read NUMLI
  29. ' Dim a field to hold the startcoord and the endcoord. 
  30. Dim LI(NUMLI,1)
  31. ' Get the datas. 
  32. For A=1 To NUMLI
  33.   Read LI(A,0),LI(A,1)
  34. Next 
  35. ' Set the three angles. Remember that these are non standard angles, 
  36. ' one full rotation is at 1024, not 360! 
  37. AX=0 : AY=512 : AZ=128
  38. ' New: BP contains the bitplane, onto which the Cube should be drawn.
  39. BP=0
  40. ' Now follow a few colour definitions. 
  41. ' C1 holds the brightest colour, C2 a middle one and C3 the darkest. 
  42. CO1=$FFF : CO2=$888 : CO3=$444
  43. Repeat 
  44.   ' Start clearing the plane to be drawn on. 
  45.    Extension_8_121C 0,BP
  46.   ' While the blitter is working, use the time to calculate the rotations. 
  47.   ' Move and set the angles. 
  48.   Add AX,5
  49.   Add AY,8
  50.   Add AZ,11
  51.    Extension_8_1138 AX,AY,AZ
  52.   ' Calculate the distances by using a sine-function and the three angles. 
  53.   POSX= Extension_8_1106(AX,300)
  54.   POSY= Extension_8_1106(AY,300)
  55.   POSZ= Extension_8_1106(AZ,500)+1500
  56.   ' Set the camera positions.
  57.    Extension_8_1122 POSX,POSY,POSZ
  58.   ' Now it's time to compute the matrix. 
  59.    Extension_8_1152 
  60.   ' So let's rotate all coordinates of the field CO()
  61.   For A=1 To NUMCO
  62.     ' Note: You only have to use the vec rot function with parameters once.
  63.     RC(A,0)= Extension_8_1168(CO(A,0),CO(A,1),CO(A,2))+160
  64.     RC(A,1)= Extension_8_1184 +128
  65.   Next 
  66.   ' It's time to finally get the lines to the screen!
  67.   For A=1 To NUMLI
  68.     ' Starting coordinates pair. 
  69.     C1=LI(A,0)
  70.     ' Ending coordinates pair. 
  71.     C2=LI(A,1)
  72.     ' Get the rotated coordinates
  73.     X1=RC(C1,0) : Y1=RC(C1,1)
  74.     X2=RC(C2,0) : Y2=RC(C2,1)
  75.     ' Draw the line on bitplane BP 
  76.      Extension_8_1016 X1,Y1 To X2,Y2, Extension_8_04F8(BP), Extension_8_04F8(BP)
  77.   Next 
  78.   ' Swap the screens to bring the object to view.
  79.   Screen Swap 
  80.   ' Now change the palette, to simulate a fade effect. 
  81.   ' It works by looking which colour appears on which planes, and giving 
  82.   ' the one being drawn the highest priority. Look at the following table: 
  83.   ' If the bit is set, which has a 1 under it, the colour must be 1, because 
  84.   ' it has the highest priority. If the bits for 2 and 3 are set, the colour 
  85.   ' must be 2 because 2 is only overlapped by the bit 1. etc.pp.lha
  86.   '                        
  87.   ' Colour-Bits      000,001,010,011,100,101,110,111   
  88.   ' Priority         321 321 321 321 321 321 321 321   
  89.   If BP=0 Then Palette 0,CO1,CO2,CO1,CO3,CO1,CO2,CO1
  90.   ' Colour-Bits      000,001,010,011,100,101,110,111   
  91.   ' Priority         213 213 213 213 213 213 213 213   
  92.   If BP=1 Then Palette 0,CO3,CO1,CO1,CO2,CO2,CO1,CO1
  93.   ' Colour-Bits      000,001,010,011,100,101,110,111   
  94.   ' Priority         132 132 132 132 132 132 132 132     
  95.   If BP=2 Then Palette 0,CO2,CO3,CO2,CO1,CO1,CO1,CO1
  96.   Wait Vbl 
  97.   ' Select next bitplane.
  98.   Add BP,1,0 To 2
  99. Until Inkey$=Chr$(27) or Mouse Key<>0
  100. Screen Close 0
  101. End 
  102. '  1_____2   
  103. ' 5/____/| 
  104. ' | |  |6| 
  105. ' |4|__|_|3  
  106. ' |/___|/
  107. ' 8    7 
  108. COORDS:
  109.   Data 8
  110. ' CUBE 
  111.   Data -100,-100,-100
  112.   Data 100,-100,-100
  113.   Data 100,-100,100
  114.   Data -100,-100,100
  115.   Data -100,100,-100
  116.   Data 100,100,-100
  117.   Data 100,100,100
  118.   Data -100,100,100
  119.  
  120. LINES:
  121.   Data 12
  122. ' CUBE 
  123.   Data 1,2
  124.   Data 2,3
  125.   Data 3,4
  126.   Data 4,1
  127.   Data 5,6
  128.   Data 6,7
  129.   Data 7,8
  130.   Data 8,5
  131.   Data 1,5
  132.   Data 2,6
  133.   Data 3,7
  134.   Data 4,8